﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;
using System.Windows.Forms;
using System.Collections.ObjectModel;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for InvoiceDataTest and is intended
    ///to contain all InvoiceDataTest Unit Tests
    ///</summary>
    [TestClass()]
    public class InvoiceDataTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for RegisterInvoice
        ///</summary>
        [TestMethod()]
        public void RegisterInvoiceTest()
        {
            Random ran = new Random(DateTime.Now.Millisecond);
            InvoiceData target = new InvoiceData(); // TODO: Initialize to an appropriate value
            Invoice invoice = new Invoice();
            invoice.Id = ran.Next(int.MaxValue).ToString();
            invoice.FullName = "Carlos";
            invoice.CI = "155224" + ran.Next(15222);
            invoice.Date = DateTime.Today;
            invoice.Detail = new Collection<InvoiceDetail>();

            InvoiceDetail detail;
            int val;
            for (int i = 0; i < 3; i++)
            {
                val = ran.Next(152);
                detail = new InvoiceDetail { Detail = "detail" + i, Mount = val.ToString() };
                invoice.Detail.Add(detail);
            }
            target.RegisterInvoice(invoice);
            
        }

        /// <summary>
        ///A test for GetEmployeInvoice
        ///</summary>
        [TestMethod()]
        public void GetEmployeInvoiceTest()
        {
            InvoiceData target = new InvoiceData(); // TODO: Initialize to an appropriate value
            DataGridView employe = new DataGridView(); // TODO: Initialize to an appropriate value
            DataGridViewTextBoxColumn CI = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn Name = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn Price = new DataGridViewTextBoxColumn();
            CI.Name = "CI";
            Name.Name = "NameClient";
            Price.Name = "Price";
            employe.Columns.AddRange(new DataGridViewColumn[] { CI, Name, Price});
            target.GetEmployeeInvoice(employe);
           
        }
    }
}
